package com.example.leetcode.theory.bean.man;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description Bean生命周期
 * @ClassName BeanLifeCycle
 * @Author Administrator
 * @Date 2020/5/19 15:24
 * @Version 1.0.0
 */
public class BeanLifeTheoryTest {

    public static void main(String[] args) {
        System.out.println("--现在开始初始化容器");

        ClassPathXmlApplicationContext factoryContext = new ClassPathXmlApplicationContext("springBeanTest/applicationContext.xml");
        System.out.println("--容器初始化成功");
//        //得到Preson，并使用
//        Person person = factoryContext.getBean("person",Person.class);
//        System.out.println(person);

        Man man=(Man)factoryContext.getBean("man");
        man.run();
//        factoryContext.close();

        System.out.println("--现在开始关闭容器！");
//        ((ClassPathXmlApplicationContext)factoryContext).registerShutdownHook();
        factoryContext.close();
    }
}
